import { ApiProperty } from '@nestjs/swagger'
import { Transform } from 'class-transformer'
import { IsNumber, IsOptional } from 'class-validator'

export class ListPaginationDto {
  /**
   * 第几页
   */
  @ApiProperty({ default: 1 })
  @Transform(({ value }) => (!value ? 1 : Number(value)))
  @IsOptional()
  @IsNumber()
  pageNo?: number

  /**
   * 每页条数
   */
  @ApiProperty({ default: 10 })
  @Transform(({ value }) => (!value ? 10 : Number(value)))
  @IsOptional()
  @IsNumber()
  pageSize?: number
}

export class ListPaginationResponse {
  list: unknown[]
  total: number
}
